﻿using System;
using MagistrAPI.MathModel;
using NUnit.Framework;

namespace TestMagistrAPI
{
    [TestFixture]
    class MathModelFunvTextFixture
    {
        [SetUp]
        public void Init()
        {
            
        }

        [Test]
        public void TestHMethod()
        {
            var h = MathModelFunc.H(3, 5, 12);
            Assert.AreEqual(Math.Round(-6360848.2920709308, 0), Math.Round(h, 0));
        }

        [Test]
        public void TestrrMethod()
        {
            var rr = MathModelFunc.Rr(3, 5, 12);
            Assert.AreEqual(Math.Round(13.3416640641, 5), Math.Round(rr, 5));
        }

        [Test]
        public void TestRMethod()
        {
            var r = MathModelFunc.R(1.1184819711);
            Assert.AreEqual(Math.Round(6360861.6337353792, 0), Math.Round(r, 0));
        }

        [Test]
        public void TestPhiuuMethod()
        {
            var phiuu = MathModelFunc.Phiuu(3, 5, 12);
            Assert.AreEqual(Math.Round(1.1184819711, 5), Math.Round(phiuu, 5));
        }

        [Test]
        public void TestMrotvMethod()
        {
            double[,] matr = { { 25000, 0, 0 }, { 0, 441666.6666666667, 0 }, { 0, 0, 441666.6666666667 } };
            double e = 10e-15;
            double[,] rezult = MathModelFunc.Mrotv(matr, e);
            double[,] expectedRezult = { { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 } };
            Assert.AreEqual(expectedRezult, rezult);
        }

        [Test]
        public void TestMatrTMethod()
        {
            double[,] matr = { { 2, 5 }, { 3, 7 } };
            double[,] expectedRezult = { { 2, 3 }, { 5, 7 } };
            Assert.AreEqual(expectedRezult, MathModelFunc.MatrT(matr, 2, 2));
        }

        [Test]
        public void TestMatrToMatrMethod()
        {
            double[,] firstMatr = { { 2, 5 }, { 3, 7 } };
            double[,] secondMatr = { { 2, 2, 1 }, { 1, 2, 1 } };
            double[,] expectedRezult = { { 9, 14, 7 }, { 13, 20, 10 } };
            Assert.AreEqual(expectedRezult, MathModelFunc.MatrToMatr(firstMatr, secondMatr, 2, 2, 3));
        }

        [Test]
        public void TestLsbUyMethod()
        {
            double[,] rezult = MathModelFunc.LsbUy(0.2, 0.4, 0.5, 0.2, 0.3, 0.1, 1.2, 0.3, 6.1);
            double[,] expectedRezult = new[,] {{0.2, 0.4, 0.5}, {0.2, 0.3, 0.1}, {1.2, 0.3, 6.1}};
            Assert.AreEqual(expectedRezult, rezult);
        }

    }
}
